Skip to content

Feature: MPEG-TS Streaming via SRT, TCP, and UDP (--stream-sink)#6721

Open
yeicor wants to merge 11 commits intoGenymobile:masterfrom
yeicor:feature/stream
Open

Feature: MPEG-TS Streaming via SRT, TCP, and UDP (--stream-sink)#6721
yeicor wants to merge 11 commits intoGenymobile:masterfrom
yeicor:feature/stream

Conversation

@yeicor
Copy link

@yeicor yeicor commented Mar 13, 2026

Overview

This PR adds a new --stream-sink option to scrcpy, allowing you to stream device video and audio as MPEG-TS to a URL using SRT, TCP, or UDP protocols. This is especially useful for integrating scrcpy with tools like OBS or other streaming clients on any OS, so it closes #467 and #5796.

Example Usage

# Start the server (also tested with UDP, UDP multicast and SRT)
scrcpy --stream-sink=tcp://0.0.0.0:1234 
scrcpy --stream-sink=tcp://0.0.0.0:1234 --video-source=camera --video-codec=h265 --video-codec-options=i-frame-interval:float=1.0 --no-playback --no-window

# Connect a client (also tested with VLC and OBS)
ffplay tcp://127.0.0.1:1234
ffplay -fflags nobuffer -flags low_delay -framedrop tcp://127.0.0.1:1234

Additional Context

  • I am not familiar with the codebase, but I was able to test that all mentioned protocols (SRT, TCP, UDP) work.
  • This feature and its code were written with the help of a Large Language Model (LLM). Please review.

Copilot AI and others added 9 commits March 13, 2026 07:59
Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
…sertion with --no-playback

Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
Co-authored-by: yeicor <4929005+yeicor@users.noreply.github.com>
Remove automatic SRT latency=50 injection and simplify CLI help.
Avoid calling avio_close() for srt:// to work around SRT/FFmpeg
epoll deadlocks; other protocols are closed normally.
Treat udp:// as connectionless and use a single output stream instead of
accepting per-client threads
Copilot AI review requested due to automatic review settings March 13, 2026 13:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new “stream sink” output path to stream the device’s video/audio as MPEG-TS over a user-provided URL, integrating it into scrcpy’s CLI/options and packet pipeline.

Changes:

  • Add a new sc_stream_sink component (stream_sink.c/.h) implementing sc_packet_sink for video/audio and handling client connections/output streaming.
  • Wire the stream sink into scrcpy.c initialization/cleanup and expose it via a new --stream-sink CLI option plus scrcpy_options.stream_sink.
  • Increase SC_PACKET_SOURCE_MAX_SINKS to allow one more packet sink.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/src/trait/packet_source.h Increase max packet sinks to allow adding the new stream sink.
app/src/stream_sink.h New public interface/type definitions for the stream sink component.
app/src/stream_sink.c New streaming implementation: URL handling, template ctx setup, client threads, fan-out queues.
app/src/scrcpy.c Initialize/start/stop/join/destroy the stream sink and add it as a packet sink.
app/src/options.h Add stream_sink option field.
app/src/options.c Default stream_sink to NULL.
app/src/cli.c Add --stream-sink CLI flag and adjust auto-disable logic for video/audio.
app/meson.build Build the new stream_sink.c source file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

yeicor and others added 2 commits March 13, 2026 14:13
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capture with OBS without scrcpy window

4 participants